package com.kuang.demo3;

import com.kuang.demo3.impl.Circle;
import com.kuang.demo3.impl.Rectangle;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title:
 * @Description:
 * @Author: zx
 * @Date: create in 13:20 2020/8/7
 * @Version: 1.0
 */
public class ProtoTypeManager {
    private Map<String, Shape> map = new HashMap<String, Shape>();

    public ProtoTypeManager() {
        map.put("Circle", new Circle());
        map.put("Rectangle", new Rectangle());
    }

    public void addShape(String key, Shape obj) {
        map.put(key, obj);
    }

    public Shape getShape(String key) {
        Shape temp = map.get(key);
        return (Shape) temp.clone();
    }
}
